<title>退款申请</title>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto" lay-filter="order-refund-index-search_from">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">退款单号</label>
                    <div class="layui-input-inline">
                        <input type="text" name="refund_no" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">用户名</label>
                    <div class="layui-input-inline">
                        <input type="text" name="username" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="order-refund-index-search_button">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                    </button>
                </div>
            </div>
        </div>

        <div class="layui-card-body">
            <table id="order-refund-index" lay-filter="order-refund-index"></table>
            <script type="text/html" id="order-refund-index-action_button">
                <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="order-refund-index-detail">详情</a>
            </script>
        </div>
    </div>
</div>
<script>
    layui.use(['common', 'table'], function () {
        var $ = layui.jquery,
            common = layui.common,
            view = layui.view,
            table = layui.table,
            form = layui.form,
            lay_id_prefix = 'order-refund-index',//当前页id前缀
            api_action_url = layui.setter.apiHost + '/order/refund';

        //表单搜索
        form.on('submit(' + lay_id_prefix + '-search_button)', function (data) {
            var field = data.field;
            field.page = 1;//默认第一页
            table.reload(lay_id_prefix, {
                where: field
            });
        });

        //表格操作
        table.render({
            elem: '#' + lay_id_prefix,
            url: api_action_url,
            toolbar: '#' + lay_id_prefix + '-toolbar_tmp',
            cols: [[
                {type: 'checkbox', fixed: 'left'},
                {field: 'id', title: 'ID', width: 80},
                {field: 'refund_no', title: '退款单号', minWidth: 250},
                {field: 'username', title: '用户名', width: 150},
                {field: 'amount', title: '退款金额', width: 120},
                {field: 'refund_type_text', title: '售后类型', width: 120},
                {field: 'status_text', title: '状态', width: 100},
                {field: 'created_at', title: '创建时间', width: 170},
                {title: '操作', width: 100, align: 'center', fixed: 'right', toolbar: '#' + lay_id_prefix + '-action_button'}
            ]],
            page: true
        });

        //监听工具条操作按钮
        table.on('tool(' + lay_id_prefix + ')', function (obj) {
            var data = obj.data;
            switch (obj.event) {
                case lay_id_prefix + '-detail':
                    common.open_window('协商历史', api_action_url, 'order/refund/detail', 'order-refund-detail', {width: '100%'}, {id: data.id});
                    break;
            }
        });
    });
</script>
